<template>
	<view class="conductBox">
		<view class="" v-if="show==1">
			<view class="materialBox">
				<view class="materialBoxTitle">
					现场物料
				</view>
				<view class="materialBoxImg">
					<image src="/static/pages/index/addition.png" mode="" class="addImg" @click="chuantu(1)"></image>
					<image :src="url+item" v-for="(item,index) in wuliao" mode="" class="addImg"></image>
				</view>
				<view class="materialBoxTitle1">
					活动人气
				</view>
				<view class="materialBoxImg">
					<image src="/static/pages/index/addition.png" mode="" class="addImg" @click="chuantu(2)"></image>
					<image :src="url+item" v-for="(item,index) in renqi" class="addImg" mode=""></image>
				</view>
				<view class="materialBoxTitle1">
					活动照片
				</view>
				<view class="materialBoxImg">
					<image src="/static/pages/index/addition.png" mode="" class="addImg" @click="chuantu(3)"></image>
					<image :src="url+item" v-for="(item,index) in zp" class="addImg" mode=""></image>
				</view>
			</view>
			<view class="queding" @click="quedingtijiao">
				<view>
					确定
				</view>
			</view>
		</view>
		<!-- 反馈之后的情况 -->
		<view class="" v-if="show==2">
			<view class="materialBox">
				<view class="materialBoxTitle">
					现场物料
				</view>
				<view class="materialBoxImg">
					<image :src="url+item" v-for="(item,index) in wuliao1" mode="" class="addImg"></image>
					
				</view>
				<view class="materialBoxTitle1">
					活动人气
				</view>
				<view class="materialBoxImg">
					<image :src="url+item" v-for="(item,index) in renqi1" class="addImg" mode=""></image>
				</view>
				<view class="materialBoxTitle1">
					活动照片
				</view>
				<view class="materialBoxImg">
					<image :src="url+item" v-for="(item,index) in zp1" class="addImg" mode=""></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {uploadImg,fankui,examineDetails} from '@/request/api.js'
	import request from "@/request/request.js"
	export default {
		data() {
			return {
				id:'',
				wuliao:[],
				renqi:[],
				zp:[],
				url:'',
				dw:'',
				show:1,
				wuliao1:[],
				renqi1:[],
				zp1:[],	
			};
		},
		onLoad(options) {
			let that = this
			that.id=options.id
			that.url=request.baseUrl
			wx.getLocation({
			 type: 'wgs84',
			 success (res) {
			   const latitude = res.latitude
			   const longitude = res.longitude
			   console.log(latitude)
			   console.log(longitude)
			   that.dw=longitude+','+latitude
			   const speed = res.speed
			   const accuracy = res.accuracy
			 }
			})
			that.getInfo()
		},
		methods:{
			getInfo(){
				let that = this
				let data={id:that.id}
				examineDetails(data).then(res=>{
					console.log(res,"附加费JFJF拒绝")
					if(res.data.feedback_two==null){
						that.show=1
					}else{
						that.show=2
						
						that.wuliao1= res.data.feedback_two.wuliao.split(",")
						that.renqi1= res.data.feedback_two.renqi.split(",")
						that.zp1= res.data.feedback_two.zhaopian.split(",")
						console.log(a,"无聊派无聊")
					}
				}).catch(err=>{
					
				})
			},
			quedingtijiao:function(){
				
				if(this.wuliao.length<=0||this.renqi.length<=0||this.zp.length<=0){
					uni.showToast({
						title:'请补充完整的信息',
						icon:'none'
					})
					
					return
				}else{
					fankui({
						id:this.id,
						wuliao:this.wuliao,
						renqi:this.renqi,
						zhaopian:this.zp,
						varchar:this.dw
					}).then(res => {		
						uni.showToast({
							title: res.msg,
							icon: "none"
						})
						setTimeout(function(){
							uni.navigateBack({
								delta:1
							})
							
						},600)
					})
				}
				
				
			},
			
			// 上传图片
			chuantu(a){
				uni.chooseImage({
				    success: (chooseImageRes) => {
				        const tempFilePaths = chooseImageRes.tempFilePaths;
						uni.showLoading({
							title:'正在上传',
							icon:'none',  
							mask:true,
							
						})
						for (var i = 0; i < tempFilePaths.length; i++) {
							uni.uploadFile({
							    url: request.baseUrl+'/api/Common/upload' , 
							    filePath: tempFilePaths[i],
							    name: 'file',
							    formData: {
							        'user': 'test'
							    },
							    success: (uploadFileRes) => {
									console.log(JSON.parse(uploadFileRes.data))
							       let b=JSON.parse(uploadFileRes.data).data.url
								   console.log(b,"图片图片图片")
								   if(a==1){
									 this.wuliao.push(b)
									 console.log(this.wuliao)
								   }
								   if(a==2){
								   	this.renqi.push(b)
								   }
								   if(a==3){
								   	 this.zp.push(b)
								   }
							    }
							});
						}
				       uni.hideLoading()
						
				    }
				});
			}
			
			
		}
		
	}
</script>

<style lang="scss">
	.queding{
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 200rpx;
		view{
			width: 340rpx;
			height: 80rpx;
			line-height: 80rpx;
			border-radius: 1000px;
			background: #1855F6;
			font-size: 30rpx;
			color: #fff;
			text-align: center;
		}
	}
page {
		background-color: #FFFFFF;
	}
	.conductBox{
		width: 100%;
		box-sizing: border-box;
		padding-bottom: 40rpx;
		overflow: hidden;
		position: relative;
		.materialBox{
			width: 670rpx;
			margin: 30rpx auto 0;
			overflow: hidden;
			.materialBoxTitle{
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #2E2F33;
				margin-left: 25rpx;
			}
			.materialBoxImg{
				margin-left: 25rpx;
				margin-top: 30rpx;
				.addImg{
					width: 200rpx;
					height: 200rpx;
					margin-right: 10rpx;
				}
			}
			.materialBoxTitle1{
				font-size: 32rpx;
				font-family: PingFang SC;
				font-weight: 500;
				color: #2E2F33;
				margin-left: 25rpx;
				margin-top: 40rpx;
			}
		}
	}
</style>
